<template>
  <div class="clientDetail">
    <!-- 头部 -->
    <div class="top">
      <img class="line_icon" src="/static/images/user/line_icon.png" alt />
      <p class="name">{{res.customerName}}</p>
      <div class="flex" style="padding-left:15px">
        <div class="flex-1" style="font-size:13px;color:#6B6B6B">
          <div class="flex align-center" style="margin:10px 0 8px">
            <img class="phone" src="/static/images/manage/phone.png" alt />
            <span style="margin-left:10px">{{res.phone}}</span>
          </div>
          <div class="flex align-center;padding-top:8px">
            <img class="papers" style src="/static/images/manage/papers.png" alt />
            <span style="margin-left:10px">{{res.certificateNumber}}</span>
          </div>
        </div>
      </div>
      <img class="topBtm" src="/static/images/user/topBtm.png" alt />
    </div>
    <!-- 内容 -->
    <div class="content">
      <div class="flex" style=" align-items: center;">
        <p class="incon"></p>
        <span class="basic">产品列表</span>
      </div>
      <div v-if="list.length>0">
        <div class="mainBody" v-for="item in list" :key="item" @click="handleJump(item)">
          <div class="flex">
            <div style="width:60%">
              <div class="flex">
                <div class="icon">
                  <!-- {{res.productAudit==='RAISING'?"募集中":(res.productAudit==='CLOSE_ACCOUNT'||res.productAudit==='SET_UP'||res.productAudit==='IN_COLLECTION')?"回款中":res.productAudit==='REMOVE_RACK'?"已下架":"已完成"}} -->
                  <span>{{item.productAudit==='REMOVE_RACK'?'已下架':(item.productAudit==='IN_COLLECTION'|| item.productAudit==='CLOSE_ACCOUNT' || item.productAudit==='SET_UP')?"回款中":item.productAudit==='COMPLETE'?"已完成":"募集中"}}</span>
                </div>
                <span style="color:#909292;font-size:12px">（{{item.productNo}}）</span>
              </div>
              <div class="name ellipsis">{{item.productName}}</div>
            </div>
            <div class="right">
              <div class="percent" v-if="item.baseComparison&&item.baseComparison.length===1">
                <span v-if="item.baseComparison[0].prop==='0'">浮动</span>
                <span v-else>{{item.baseComparison[0].prop}}%</span>
              </div>
              <div class="percent" v-if="item.baseComparison&&item.baseComparison.length>1">
                <span
                  v-if="item.baseComparison[0].prop==='0' && item.baseComparison[item.baseComparison.length-1].prop==='0'"
                >浮动</span>
                <span
                  v-else
                >{{item.baseComparison[0].prop}}%~{{item.baseComparison[item.baseComparison.length-1].prop}}%</span>
              </div>
              <div class="month" v-if="item.raisingPeriod">{{item.raisingPeriod}}个月</div>
              <!-- <div
                class="percent"
                v-if="item.baseComparison.length===1"
              >{{item.baseComparison[0].prop}}%</div>-->
              <!-- <div
                class="percent"
                v-else
              >{{item.baseComparison[0].prop}}%~{{item.baseComparison[item.baseComparison.length-1].prop}}%</div>
              <div class="month" v-if="item.raisingPeriod">{{item.raisingPeriod}}个月</div>-->
            </div>
          </div>
        </div>
      </div>
      <!-- 无活动-->
      <div class="empty" v-else>
        <div style="text-align:center">
          <img class="emptyIcon" src="/static/images/user/collect_icon.png" alt />
          <p style="font-size:14px;color:#909292">暂无数据</p>
        </div>
        <!-- <notDatas item="暂无数据" /> -->
      </div>
      <div class="activeMore" v-if="!loadMore && list.length>0">—— 已经到底啦 ——</div>
    </div>
    <!-- button -->
    <div class="btm" @click="jumpClect">
      <div class="btn">选择产品</div>
    </div>
  </div>
</template>
<script>
import notDatas from "@/components/notDatas";
import { functionCustomer } from "@/api/api";
export default {
  data() {
    return {
      // 列表分页
      formData: {
        pageIndex: 1,
        pageSize: 10,
        id: ""
      },
      list: [],
      loadMore: true,
      res: {}
    };
  },
  components: { notDatas },
  mounted() {
    Object.assign(this.$data, this.$options.data());
    console.log(this.$mp.query);
    this.res.certificateNumber = this.$mp.query.certificateNumber;
    this.res.phone = this.$mp.query.phone;
    this.res.customerName = this.$mp.query.customerName;
    this.formData.id = this.$mp.query.id;
    this.functionCustomer();
  },
  // 上拉加载更多
  onReachBottom() {
    this.functionCustomer();
  },
  methods: {
    /** 产品详情 */
    handleJump(item) {
      wx.navigateTo({
        url: `/pages/PersonalCenter/userChildren/productDetail/main?id=${
          item.id
        }&productId=${item.productId}`
      });
    },
    /** 产品分页 */
    async functionCustomer() {
      if (this.loadMore) {
        wx.showLoading({
          title: "加载中",
          mask: true
        });
        await functionCustomer(this.formData).then(res => {
          wx.hideLoading();
          if (!res.code) {
            var data = res.list;
            this.list = this.list.concat(data);
            ++this.formData.pageIndex;
            if (res.pages < this.formData.pageIndex) {
              this.loadMore = false;
            }
          }
        });
      }
    },
    /** 选择产品 */
    jumpClect() {
      wx.navigateTo({
        url: `/pages/PersonalCenter/userChildren/selsect/main?realId=${
          this.formData.id
        }&customerName=${this.res.customerName}&phone=${this.res.phone}`
      });
    }
  }
};
</script>
<style lang="less" scoped>
.clientDetail {
  padding: 25px 15px 0 15px;
  .empty {
    .emptyIcon {
      margin: 20px 0;
      width: 229px;
      height: 175px;
    }
  }
  .btm {
    padding: 6px 0;
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    border-top: 0.5px solid #e6e6e6;
    background: #fff;
    z-index: 2;
    .btn {
      height: 42px;
      background: rgba(24, 119, 152, 1);
      border-radius: 2px;
      line-height: 42px;
      font-size: 15px;
      color: #fff;
      text-align: center;
      margin: 0 15px;
    }
  }
  .content {
    padding: 20px 0 70px 0;
    .incon {
      width: 5px;
      height: 17px;
      background: linear-gradient(
        360deg,
        rgba(255, 255, 255, 1) 0%,
        rgba(53, 181, 175, 1) 100%
      );
      border-radius: 3px;
    }
    .basic {
      font-size: 18px;
      color: #020604;
      margin-left: 10px;
      font-weight: bold;
    }
    .right {
      border-left: 1px solid #e6e7e3;
      // padding-left: 25px;
      width: 40%;
      text-align: center;
    }

    .mainBody {
      padding: 23px 0;
      border-bottom: 0.5px solid #e6e6e6;
    }
    .percent {
      font-size: 22px;
      color: #f45247;
      font-weight: bold;
    }
    .month {
      font-size: 12px;
      color: #909292;
      margin-top: 6px;
    }
    .name {
      padding-right: 24px;
      margin-top: 7px;
      font-size: 16px;
      font-weight: bold;
      color: #020604;
    }
    .label {
      padding: 2px 10px;
      background: #f3f7f8;
      border-radius: 2px;
      color: #187798;
      font-size: 12px;
      margin-right: 5px;
    }
    .icon {
      background: url("https://qinghe-zichan.oss-cn-shanghai.aliyuncs.com/imgs/collect.png");
      background-repeat: no-repeat;
      background-size: 100% 100%;
      width: 51px;
      height: 20px;
      font-size: 10px;
      color: #fff;
      text-align: center;
      line-height: 20px;
      position: relative;
      img {
        position: absolute;
        top: 0;
        left: 0;
        width: 51px;
        height: 20px;
      }
      span {
        color: #fff;
        position: absolute;
        left: 6px;
      }

      // background-size: 100% 100%;
    }
  }
  .top {
    box-shadow: 0px 0px 20px 0px rgba(2, 6, 4, 0.06);
    .name {
      padding: 16px 0 10px 15px;
      color: #020604;
      font-size: 18px;
      font-weight: bold;
    }
    .line_icon {
      width: 100%;
      height: 3px;
      display: block;
    }
    .phone {
      width: 11px;
      height: 11px;
    }
    .papers {
      width: 14px;
      height: 12px;
    }
    .topBtm {
      display: block;
      width: 100%;
      height: 58px;
    }
  }
}
</style>